package baomidou.service.model;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author zhanglinfeng
 * @date create in 2023/3/6 11:48
 */
public abstract class BaseEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 896899552586049762L;

    /** id */
    @TableId(type = IdType.AUTO)
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Integer id;

    /** 创建时间 */
    @TableField(value = "create_time", updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;

    /** 创建人 */
    @TableField(value = "created_by", updateStrategy = FieldStrategy.NEVER)
    private Integer createdBy;

    /** 更新时间 */
    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    /** 更新人 */
    @TableField(value = "updated_by")
    private Integer updatedBy;

    /** 版本 默认 1*/
    @Version
    @TableField(value = "version", update = "%s+1" )
    private Integer version;

    /** 1 可见，0 不可见 默认 1**/
    @TableField(value = "visible")
    private Integer visible;

    /** 1 有效，0 无效 默认 1**/
    @TableField(value = "valid")
    private Integer valid;

    /** 1 已删除，0 未删除 默认 0**/
    @TableField(value = "deleted", select = false)
    @TableLogic
    private Integer deleted;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Integer getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Integer createdBy) {
        this.createdBy = createdBy;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(Integer updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Integer getVisible() {
        return visible;
    }

    public void setVisible(Integer visible) {
        this.visible = visible;
    }

    public Integer getValid() {
        return valid;
    }

    public void setValid(Integer valid) {
        this.valid = valid;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }
}
